<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>

<!-- 引入基础的Ext的JS和CSS文件-->
<%@ include file="/common/meta_ext.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx}/common/public/js/wizard/ext-ux-wiz.css" />

<!-- 引入所需的扩展组件 -->
<script src="${ctx}/common/system/public/js/wizard/Wizard.js" type="text/javascript"></script>
<script src="${ctx}/common/system/public/js/wizard/Header.js" type="text/javascript"></script>
<script src="${ctx}/common/system/public/js/wizard/Card.js" type="text/javascript"></script>

<script src="${ctx}/common/system/public/js/CheckTree.js" type="text/javascript"></script>
<script src="${ctx}/resources/js/aos/ext_ux/BasicGrid.js" type="text/javascript"></script>
<script src="${ctx}/resources/js/aos/ext_ux/CrudGrid.js" type="text/javascript"></script>
<script src="${ctx}/common/system/public/js/SortGrid.js" type="text/javascript"></script>
<script src="${ctx}/common/system/public/js/UserGrid.js" type="text/javascript"></script>
<script src="${ctx}/common/system/public/js/MenuGrid.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/UserSearchConditionPanel.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/MenuSearchConditionPanel.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/UserQueryPanel.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/UserQueryByShortcutPanel.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/MenuQueryPanel.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/ShortcutQueryByUserPanel.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/SelectUsersWindow.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/SelectInsertPosPanel.js" type="text/javascript"></script>
<script src="${ctx}/common/system/org/js/ac-user-shortcut/AddShortcutWizard.js" type="text/javascript"></script>

<script type="text/javascript">
Ext.onReady(function(){
	Ext.QuickTips.init();
	
	//用户查询面板，包括系统中所有的用户
	var userQueryPanel = new Ext.ux.org.acusershortcut.UserQueryPanel({
			url: 'om-user!list.action',
			id: 'userQueryPanel', 
			region: 'west', 
			width: '50%'
	});
	
	//与用户对应的快捷菜单面板
	var shortcutQueryByUserPanel = new Ext.ux.org.acusershortcut.ShortcutQueryByUserPanel({
		id: 'shortcutQueryByUserPanel',
		region: 'center',
		url: 'ac-user-shortcut!getShortcutsOwnedByUser.action'
	});
	
	//用户查询面板中对选择每一条用户所做的事件处理
	userQueryPanel.on('userSelect', function(userId){
		shortcutQueryByUserPanel.reloadByUser(userId);
	});
	
	userQueryPanel.on('multiUsersSelect', function(){
		shortcutQueryByUserPanel.clear();
	});
	
	//按用户管理快捷菜单面板
	var byUserPanel = new Ext.Panel({
		title: '按用户管理',
		layout: 'border',
		items: [userQueryPanel, shortcutQueryByUserPanel]
	});
	
	//菜单查询面板，包括系统中所有的菜单
	var menuQuery = new Ext.ux.org.acusershortcut.MenuQueryPanel({
			id: 'menuQuery',
			url: 'ac-menu!getAllMenusAssociateFunc.action', 
			region: 'west', 
			width: '50%'
	});
	
	//与菜单对应，使用该菜单作为快捷菜单的用户查询面板
	var userQueryByShortcutPanel = new Ext.ux.org.acusershortcut.UserQueryByShortcutPanel({
			id: 'userQueryByShortcutPanel',
			url: 'om-user!getUsersOfShortcut.action',
			region: 'center'
		});
	
	//菜单面板中对选择每一条菜单所做的事件处理	
	menuQuery.on('menuSelect', function(menuId){
		userQueryByShortcutPanel.reloadByMenu(menuId);
	});
	
	//按照菜单管理快捷菜单
	var byMenuPanel = new Ext.Panel({
		title: '按菜单管理',
		layout: 'border',
		items: [menuQuery, userQueryByShortcutPanel]
	});
	
	//Tab面板
	var tabPanel = new Ext.TabPanel({
		region: 'center',
		margins: '1 1 1 1',
		border: true,
		activeTab: 0
	});
	
	tabPanel.add(byUserPanel);
	tabPanel.add(byMenuPanel);
	
	var viewport = new Ext.Viewport({
		layout: 'border',
		items: [tabPanel]
	});
	
	var gridDropTargetEl = shortcutQueryByUserPanel.gridPanel.getView().el.dom.childNodes[0].childNodes[1]

	//定义拖拉对象，可以实现对快捷菜单的排序
	var destGridDropTarget = new Ext.dd.DropTarget(gridDropTargetEl, {
		ddGroup    : 'gridDDGroup',
		copy       : false,
			
		notifyDrop : function(ddSource, e, data){
				
			var t = e.getTarget();
			var v = shortcutQueryByUserPanel.gridPanel.view;
			var row = v.findRowIndex(t);
			var selectRowIndex = new Array();
			for(var i = ddSource.dragData.selections.length - 1; i >= 0 ; i--){
				var item = ddSource.dragData.selections[i];
				var rowIndex = shortcutQueryByUserPanel.gridPanel.getRowIndex(item);
				shortcutQueryByUserPanel.gridPanel.store.removeAt(rowIndex);
				shortcutQueryByUserPanel.gridPanel.store.insert(row, item);
				selectRowIndex.push(row);
				row = row + 1;
			}
			shortcutQueryByUserPanel.gridPanel.getSelectionModel().selectRows(selectRowIndex);
			return(true);
		}
	});
	
});
</script>
</head>
<body>
</body>
</html>